﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/assets/libs/layui/css/layui.css" />
    <link rel="stylesheet" href="/assets/module/admin.css?v=318">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .form-div {
            padding: 20px;
            background-color: white;
            margin: 15px;
        }
    </style>
</head>
<body>
    <div class="layui-row form-div">
        <form id="dataform" lay-filter="dataform" class="layui-form model-form" style="padding-top:10px;">
            <input name="roleId" type="hidden" />
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required" style="padding-left: 0;width: 95px;">字典项名称:</label>
                <div class="layui-input-block">
                    <input name="DictValue" placeholder="请输入字典项名称" class="layui-input"
                           lay-verType="tips" lay-verify="required" required />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required" style="padding-left: 0;width: 95px;">字典项代码:</label>
                <div class="layui-input-block">
                    <input name="DictKey" placeholder="请输入字典键" class="layui-input" type="number"
                           lay-verType="tips" lay-verify="required|number" required />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">排序号:</label>
                <div class="layui-input-block">
                    <input name="DictSort" placeholder="请输入排序号" class="layui-input" type="number"
                           lay-verType="tips" lay-verify="required" required />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">是否默认:</label>
                <div class="layui-input-block">
                    <input type="radio" name="IsDefault" value="1" title="默认">
                    <input type="radio" name="IsDefault" value="0" title="否" checked>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">是否禁用:</label>
                <div class="layui-input-block">
                    <input type="radio" name="DictStatus" value="1" title="启用" checked>
                    <input type="radio" name="DictStatus" value="0" title="禁用">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注:</label>
                <div class="layui-input-block">
                    <input name="Remark" placeholder="请输入备注" class="layui-input" type="text" />
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn" lay-filter="formSubmit" lay-submit>保存</button>
            </div>
        </form>
    </div>

    <!-- 初始加载动画 -->
    <div class="page-loading">
        <div class="signal-loader">
            <span></span><span></span><span></span><span></span>
        </div>
    </div>

    <!-- js部分 -->
    <script src="/assets/libs/jquery/jquery-3.2.1.min.js"></script>
    <script src="/assets/libs/layui/layui.js"></script>
    <script src="/assets/js/main.js"></script>
    <script src="/assets/js/utils.js"></script>
    <script type="text/javascript">
        var id = getRequestData("id");
        var DictType = getRequestData("DictType");
        layui.use(['layer', 'form', 'admin', 'laydate', 'formX'], function () {
            var layer = layui.layer;
            var form = layui.form;
            var admin = layui.admin;
            var formX = layui.formX;
            var laydate = layui.laydate;
            var setter = layui.setter;
            /* // 时间弹窗模板
            laydate.render({
                elem: '#StartTime'
                , type: 'datetime'
                , trigger: 'click'
            });
            */
            // 初始化
            if (id > 0) {
                admin.req('/SystemManage/DataDictDetail/GetFormJson', { id: id }, function (res) {
                    admin.removeLoading();
                    if (res.Tag == 1) {
                        form.val('dataform', res.Data);
                    }
                }, 'get');
            } else {
                admin.removeLoading();
            }

            // 表单提交
            form.on('submit(formSubmit)', function (data) {
                data.field.Id = id;
                data.field.DictType = DictType;
                admin.showLoading('body', 3, '.8');

                admin.req('/SystemManage/DataDictDetail/SaveFormJson', data.field, function (res) {
                    admin.removeLoading('body', true, true);
                    if (res.Tag == 1) {
                        parent.layer.msg('操作成功', { icon: 1, time: 1500 });
                        parent.table.reload('gridTable2');
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    }
                    else {
                        layer.msg(res.Message, { icon: 2 });
                    }
                }, 'post');

                return false;
            });
        });
    </script>
</body>
</html>